package aufgabe1;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ArrayReader {

	private static String text;
	private static int[] intArr;
	private static String path;

	public ArrayReader(String path) {

		ladeDatei(path);
	}

	public void ladeDatei(String path) {

		File file = new File(path);

		if (!file.canRead() || !file.isFile())
			System.exit(0);

		FileReader fr = null;
		int c;
		StringBuffer buff = new StringBuffer();
		try {
			fr = new FileReader(file);
			while ((c = fr.read()) != -1) {
				buff.append((char) c);

			}
			fr.close();

		} catch (IOException e) {
			e.printStackTrace();
		}
		text = buff.toString();

	}

	public static ArrayList<Integer> getText() {

		String[] strArr;
		strArr = text.split(" ");

		ArrayList<Integer> arrList = new ArrayList<Integer>();

		for (int i = 0; i <= strArr.length - 1; i++) {
			arrList.add(Integer.parseInt(strArr[i]));
		}

		return arrList;
	}

}
